package com.itheima.sc.web.sms;

import com.itheima.sc.pojo.sms.HomeRecommendSubject;
import com.itheima.sc.result.Result;
import com.itheima.sc.service.sms.SmsHomeRecommendSubjectService;
import com.itheima.sc.vo.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/home/recommendSubject")
public class SmsHomeRecommendSubjectController {

    @Autowired
    private SmsHomeRecommendSubjectService recommendSubjectService;

    //添加首页推荐
    @PostMapping("/create")
    public Result addRecommendSubject(@RequestBody List<HomeRecommendSubject> RecommendSubjects){
        recommendSubjectService.addRecommendSubjects(RecommendSubjects);
        return Result.success(null);
    }

    //批量删除推荐
    @PostMapping("/delete")
    public Result deleteRecommendSubject(@RequestParam List<Long> ids){
        recommendSubjectService.deleteRecommendSubjects(ids);
        return Result.success(null);
    }
    //分页查询首页推荐
    @GetMapping("/list")
    public Result selectRecommendSubjectList(@RequestParam Map<String,String> param){
        PageResult pageResult=recommendSubjectService.selectRecommendSubjectList(param);
        return Result.success(pageResult);
    }
    //批量修改首页推荐状态
    @PostMapping("/update/recommendStatus")
    public Result updateRecommendSubjectStatus(@RequestParam List<Long> ids,@RequestParam("recommendStatus") Integer status){
        recommendSubjectService.updateRecommendSubjectStatus(ids,status);
        return Result.success(null);
    }
    //修改首页推荐
    @PostMapping("/update/sort/{id}")
    public Result updateRecommendSubjectSort(@PathVariable Long id,Integer sort){
        recommendSubjectService.updateRecommendSubjectSort(id,sort);
        return Result.success(null);
    }
}
